package com.dyz.leetcode._01_array;

public class _605_canPlaceFlowers {
    public boolean canPlaceFlowers(int[] flowerbed, int n) {
        int len = flowerbed.length;
        int i =0;
        while(i<len){
            if(flowerbed[i]==1){
                i+=2;
            }else if(i!=len-1 && flowerbed[i]==0 && flowerbed[i+1]==1){
                i+=3;
            }else{
                n--;
                i+=2;
            }
        }
        return n<=0;
    }

    public static void main(String[] args) {
        int[] flowerbed  = {1,0,0,0,0,1};
        new _605_canPlaceFlowers().canPlaceFlowers(flowerbed, 2);
    }
}
